package apof.model
{
	public class ConsumeType extends ApofModel
	{
		/**
		 * 约定：
		 * ctid=0: root
		 * 1: expense
		 * 2: income
		 * 3: 转帐 
		 * **/
		public var ctid : int;
		public var name : String;
		public var editable : Boolean;
		public var appendable : Boolean;
		public var cnstraint : int;
		public var uid : int = -1;
		public var parentCtid : int = -1;
		public var rank : int;
		
		
		public var subTypes : Array=new Array();
		public var budgetItems:Array=new Array();
		public var parent : ConsumeType=null;
		
		public var user:User=null;
		public var transections:Array=new Array();
		
		//private static var init:Boolean = onInit();
		public static function onInit():Boolean {
			var pt:Object=prototype;
			pt.classname="ConsumeType";			
			pt.fields=[		"name",			"ctid",		"cnstraint",	"parentCtid",	"editable",	"appendable",	"uid",		"rank"];
			pt.fieldTypes=[	"VARCHAR(60)",	"INTEGER",	"INTEGER",		"INTEGER",		"BIT",		"BIT",			"INTEGER",	"INTEGER"];
			pt.primaryKey="ctid";  
			pt.foreignKey={	"uid":			{"linkto":User,			"aggregate":false,	"ref":"user",	"peerlink":"consumeTypes"},
							"parentCtid":	{"linkto":ConsumeType,	"aggregate":false,	"ref":"parent",	"peerlink":"subTypes"},
							"subTypes":		{"linkto":ConsumeType,	"aggregate":true,	"ref":"subTypes","peerlink":"parentCtid"},
							"transections": {"linkto":Transection,	"aggregate":true,	"ref":"transections","peerlink":"ctid"},
							"budgetItems": {"linkto":BudgetItem,	"aggregate":true,	"ref":"budgetItems","peerlink":"ctid"}
							
							};
			
			return true;
		}
		
		public override function get classInfo():Object {return prototype;}
		public static function get classInfo():Object {return prototype;}
	}
}